"""
dfs超时了。。。
"""


class Solution:
    def removeKdigits(self, num: str, k: int) -> str:
        min_value = float("inf")
        count = 0
        length = len(num) - k
        if length <= 0:
            return 0

        def dfs(s, start):
            nonlocal min_value, count
            count += 1
            print(s, start)
            if len(s) == length:
                min_value = min(min_value, int(s))
                return
            for i in range(start, len(num)):
                dfs(s + num[i], i + 1)

        dfs("", 0)
        print("count=", count)
        return min_value


if __name__ == "__main__":

    res = Solution().removeKdigits("1432219", 3)
    print(res)
